package de.projectgoodmorning.alarm.storage;

import android.test.AndroidTestCase;
import de.projectgoodmorning.alarm.model.gateway.CombinedAlarm;
import de.projectgoodmorning.alarm.model.generic.Alarm;
import de.projectgoodmorning.alarm.storage.AlarmStorage;

public class AlarmStorageTest extends AndroidTestCase {

	private AlarmStorage storage;
	
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		storage = new AlarmStorage( getContext() );
	}
	
	public void test_it_should_save_alarm() {
		int size = storage.toArray().length;

		Alarm mainAlarm = new Alarm( 0, null );
		CombinedAlarm alarm = new CombinedAlarm( mainAlarm );
		storage.add( alarm );
		
		assertTrue( storage.toArray().length == (size+1) );
	}
	
	public void test_it_should_remove_alarm() {
		int size = storage.toArray().length;
		storage.remove( 0 );
		assertTrue( storage.toArray().length == (size-1) );
	}
	
	public void test_it_should_remove_all_alarms() {
		storage.removeAll();
		assertTrue( storage.toArray().length == 0 );
	}
}
